import { makeAutoObservable } from 'mobx'
import { http, setToken, getToken, clearToken } from '@/utils/index'

class LoginStore {
  token = getToken() || ''
  constructor() {
    makeAutoObservable(this)
  }
  login = async (data) => {
    const res = await http.post('/authorizations', data)
    this.token = res.data.data.token
    setToken(res.data.data.token)
  }
  loginOut = () => {
    this.token = ''
    clearToken()
  }
}
export default LoginStore